/// <reference path="../_variables.scss" />
/// <reference path="../_functions.scss" />
/// <reference path="../_mixins.scss" />

@mixin caret-down() {
  border-top: var(--caret-width) solid;
  border-inline-end: var(--caret-width) solid transparent;
  border-bottom: 0;
  border-inline-start: var(--caret-width) solid transparent;
}

@mixin caret-up() {
  border-top: 0;
  border-inline-end: $caret-width solid transparent;
  border-bottom: $caret-width solid;
  border-inline-start: $caret-width solid transparent;
}

@mixin caret-right() {
  border-top: $caret-width solid transparent;
  border-inline-end: 0;
  border-bottom: $caret-width solid transparent;
  border-inline-start: $caret-width solid;
}

@mixin caret-left() {
  border-top: $caret-width solid transparent;
  border-inline-end: $caret-width solid;
  border-bottom: $caret-width solid transparent;
}

@mixin caret($direction: down) {
  @if $enable-caret {
    &::after {
      --caret-width: #{$caret-width};
      display: inline-block;
      margin-inline-start: $caret-spacing;
      vertical-align: $caret-vertical-align;
      content: "";
      @if $direction == down {
        @include caret-down();
      } @else if $direction == up {
        @include caret-up();
      } @else if $direction == right {
        @include caret-right();
      }
    }

    @if $direction == left {
      &::after {
        display: none;
      }

      &::before {
        display: inline-block;
        margin-inline-end: $caret-spacing;
        vertical-align: $caret-vertical-align;
        content: "";
        @include caret-left();
      }
    }

    &:empty::after {
      margin-inline-start: 0;
    }
  }
}
